#pragma once
#include "IVRNode.h"
#include <string>
#include "v8.h"


//convert this class to v8 template, so js could use it.thanks god.
namespace IVRFlow{
	class CPlayVoiceNode:
		public CIVRNode
	{
	private:
		std::string m_voiceFilePath;
	public:
		CPlayVoiceNode(void);
		~CPlayVoiceNode(void);
		virtual int Enter(void);
		/*std::string ObjectToString(v8::Local<v8::Value> value) 
		{
			v8::String::Utf8Value utf8_value(value);
			return std::string(*utf8_value);
		}
		v8::Handle<v8::Value> setFilePath(const v8::Arguments& args)
		{
			m_voiceFilePath = ObjectToString(args[0]);
			return v8::Integer::New(0);
		}*/
		
		//bool playVoiceFile(std::string path);
		void play();
		void setVoiceFile(std::string path);
		void stop();
		virtual void processKeyRecived(std::string key);
		virtual void processPlayFinished();
	private:
		std::vector<std::string> m_playFinishedJScript;
		std::string m_voiceFile;
	};
}
